import Request from 'utils/request';

export default class MinAuthApi {
  static authLogin(data) {
    const apiName = 'api/wechatMiniProgram/getCodeFromWechatAuth';
    return Request.post(apiName, {
      code: data.code,
      iv: data.iv,
      encryptedData: data.encryptedData
    }).then(res => {
      let resData = res.data;
      let weChatUserInfo = resData.sessionInfo.weChatUserInfo;
      return {
        authToken: resData.auth_token,
        refreshToken: resData.refresh_token,
        user: weChatUserInfo
      };
    });
  }
}
